package org.anachronos.jeep.ui.trace;

import org.anachronos.jeep.core.agent.ProfilerRemoteControl;
import org.anachronos.jeep.core.attach.VirtualMachineAttachement;
import org.anachronos.jeep.core.attach.VirtualMachineAttachement.State;
import org.anachronos.jeep.ui.attach.VirtualMachineAttachementCommand;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;

public class StopProfilingCommand extends VirtualMachineAttachementCommand {

	@Override
	public Object execute(final ExecutionEvent event) throws ExecutionException {
		final ProfilerRemoteControl profilerRemoteControl = getProfilerRemoteControl(event);
		profilerRemoteControl.stopProfiling();
		final VirtualMachineAttachement selection = getSelection(event);
		selection.setState(State.ATTACHED);
		return null;
	}

}
